<template>
  <div class="xsht_box">
    <header-comm></header-comm>
    <div class="header_sele" :style="$parent.$parent.collapsed==false?'left: 10%':'left:80px'">
      <div></div>
      <div class="add_qy">
        <a-input placeholder="请输入要查询的关键字" v-model="searval" @change="search" />
      </div>
    </div>
    <div class="bcg">
      <div class="bbgl">
        <a-table :columns="columns" :pagination="pagination" :dataSource="data" bordered>
          <template slot="annex" slot-scope="text, record, index">
            <div class="down_box">
              <span class="del">
                <a :href="record.annex" target="view_frame">
                  下载
                  <a-icon class="ico" type="cloud-download" />
                </a>
              </span>
            </div>
          </template>
          <template slot="operation" slot-scope="text, record, index">
            <span class="del" @click="deleter(record.key)">删除</span>
          </template>
        </a-table>
      </div>
    </div>
  </div>
</template>

<script>
import qs from "qs";
import headerComm from "../header-comm/header.vue";
const columns = [
  {
    title: "客户名称",
    dataIndex: "username"
  },
  {
    title: "联系电话",
    dataIndex: "phone"
  },
  {
    title: "公司名称",
    dataIndex: "companyName"
  },
  {
    title: "内容",
    dataIndex: "annex",
    scopedSlots: { customRender: "annex" }
  },
    {
    title: "提交时间",
    dataIndex: "dateline",
    scopedSlots: { customRender: "dateline" }
  },
//   {
//     title: "备注",
//     dataIndex: "bz"
//   },
  {
    title: "操作",
    dataIndex: "operation",
    scopedSlots: { customRender: "operation" }
  }
];
const data = [];
export default {
  data() {
    return {
      data,
      columns,
      pagination: {
        defaultPageSize: 10,
        showTotal: total => `共 ${total} 条数据`,
        total: 0,
        current: 1
      },
      remark: "",
      shyyval: {
        key: "",
        val: ""
      },
      searval: ""
    };
  },

  methods: {
    getydzListt(pagination) {
      this.pagination.current = pagination.current;
      this.axios
        .post(
          "fhl/xunjia/productDzList.php",
          qs.stringify({
            sqdwid: this.$store.state.bbl_sqdwid,
            page: this.pagination.current,
            pageSize: pagination.defaultPageSize,
            type: "8",
            filed: this.searval
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.code == 303) {
            this.pagination.total = res.data.total;
            for (var i = 0; i < res.data.result.data.length; i++) {
              res.data.result.data[i].key = res.data.result.data[i].id_num;
            }
            this.data = res.data.result.data;
          } else {
            this.data = [];
          }
        });
    },

    search() {
      this.getydzListt(this.pagination);
    },
   deleter(key) {
      this.axios
        .post(
          "fhl/xunjia/productDzDelete.php",
          qs.stringify({
            id_num: key
          })
        )
        .then(res => {
          if (res.data.code == 303) {
            this.getydzListt(this.pagination);
            this.$notification["success"]({
              message: "成功",
              description: res.data.msg
            });
          } else {
            this.$notification["error"]({
              message: "失败",
              description: res.data.msg
            });
          }
        });
    },
  },
  components: {
    headerComm
  },

  created() {
    this.getydzListt(this.pagination);
  }
};
</script>

<style lang='less'>
.xsht_box{
.header_sele {
  position: absolute;
  top: 55px;
  left: 200px;
  z-index: 999;
  text-align: right;
  width: 90%;
  background-color: #fff;
  box-shadow: 5px 5px 5px #ccc;
  // height: 50px;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.bbgl {
  position: relative;
  top: 143px;
  left: 1%;
  background: #fff;
  width: 98%;
}
.shyy_tk {
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.5);
  width: 100%;
  height: 1000px;
  z-index: 999;
  .sryy {
    position: absolute;
    left: 35%;
    top: 10%;
    width: 30%;
    background: #fff;
    height: 246px;
    text-align: center;
    padding: 46px;
    textarea {
      width: 96%;
    }
    .btn {
      margin-top: 20px;
      text-align: center;
    }
  }
}
}

</style>
